package com.huawei.gamebox.service.welfare.gift.node;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.welfare.common.card.GsTitleCard;
import com.huawei.gamebox.service.welfare.gift.bean.GameGiftCardListBean;
import com.huawei.gamebox.service.welfare.gift.card.BaseGiftCard;
import com.huawei.gamebox.service.welfare.gift.card.VerticalScrollGameGiftListCard;
import java.util.List;
import o.chy;
import o.chz;
import o.cih;
import o.epv;
import o.CollectCheck;
import o.exp.j;
import o.fcc;

public class VerticalGameGiftListLineNode extends BaseGiftNode {
    private chy ᐝ;

    public VerticalGameGiftListLineNode(Context context) {
        super(context);
    }

    protected View ˊ(LayoutInflater layoutInflater) {
        if (layoutInflater == null) {
            return null;
        }
        int i = j.ॱʽ;
        if (ˋ()) {
            i = j.ͺ;
        }
        RelativeLayout relativeLayout = (RelativeLayout) layoutInflater.inflate(i, null);
        if (relativeLayout == null) {
            return relativeLayout;
        }
        int ˎ = ˎ();
        relativeLayout.setPadding(ˎ, 0, ˎ, 0);
        return relativeLayout;
    }

    public boolean ॱ() {
        return true;
    }

    public boolean ˊ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        layoutParams.weight = 1.0f;
        int ˏ = ˏ();
        new RelativeLayout.LayoutParams(-1, 1).setMargins(0, 0, 0, 0);
        for (int i = 0; i < ˏ; i++) {
            cih verticalScrollGameGiftListCard = new VerticalScrollGameGiftListCard(this.ॱ);
            LinearLayout linearLayout = (LinearLayout) this.ˊ.inflate(j.ˋˊ, null);
            GsTitleCard gsTitleCard = new GsTitleCard(this.ॱ);
            View ॱ = ॱ(this.ˊ);
            if (ॱ != null) {
                gsTitleCard.ˏ(ॱ);
                verticalScrollGameGiftListCard.ॱ(gsTitleCard);
                linearLayout.addView(ॱ);
            }
            View linearLayout2 = new LinearLayout(this.ॱ);
            LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-1, -2);
            linearLayout2.setOrientation(1);
            linearLayout2.setLayoutParams(layoutParams2);
            verticalScrollGameGiftListCard.ˏ(linearLayout2);
            linearLayout.addView(linearLayout2);
            ˊ(verticalScrollGameGiftListCard);
            viewGroup.addView(linearLayout, layoutParams);
        }
        return true;
    }

    public boolean ॱ(chz o_chz, ViewGroup viewGroup) {
        int ˏ = ˏ();
        this.ˏ = o_chz.ˏ;
        for (int i = 0; i < ˏ; i++) {
            cih ˎ = ˎ(i);
            if (ˎ instanceof VerticalScrollGameGiftListCard) {
                VerticalScrollGameGiftListCard verticalScrollGameGiftListCard = (VerticalScrollGameGiftListCard) ˎ;
                CardBean ˋ = o_chz.ˋ(i);
                if (ˋ instanceof GameGiftCardListBean) {
                    ˋ.ˋˋ(String.valueOf(this.ˏ));
                    List ˊ = ((GameGiftCardListBean) ˋ).ˊ();
                    if (CollectCheck.isEmpty(ˊ)) {
                        ˎ.ˉ().setVisibility(8);
                    } else {
                        int size = ˊ.size();
                        if (epv.ˏॱ(this.ॱ)) {
                            ॱ(verticalScrollGameGiftListCard, size, 2);
                        } else {
                            ˊ(verticalScrollGameGiftListCard, size);
                        }
                        ˎ.ˏ(ˋ);
                        ˎ.ˉ().setVisibility(0);
                    }
                } else {
                    ˎ.ˉ().setVisibility(8);
                }
            }
        }
        return true;
    }

    protected chy ᐝ() {
        return this.ᐝ;
    }

    public void ˋ(chy o_chy) {
        this.ᐝ = o_chy;
        for (int i = 0; i < ˊॱ(); i++) {
            VerticalScrollGameGiftListCard verticalScrollGameGiftListCard = (VerticalScrollGameGiftListCard) ˊ(i);
            if (verticalScrollGameGiftListCard != null) {
                verticalScrollGameGiftListCard.ˊ().ॱ(o_chy);
                int i2 = 0;
                while (i2 < verticalScrollGameGiftListCard.ˋ()) {
                    fcc o_fcc = (fcc) verticalScrollGameGiftListCard.ˊ(i2);
                    if (o_fcc != null) {
                        o_fcc.ॱ(o_chy);
                        View ˉ = o_fcc.ˉ();
                        if (ˉ != null) {
                            ˉ.setClickable(true);
                        }
                        i2++;
                    } else {
                        return;
                    }
                }
                continue;
            }
        }
    }

    protected BaseGiftCard ˏ(boolean z) {
        BaseGiftCard o_fcc = new fcc(this.ॱ, z);
        o_fcc.ॱ(true);
        return o_fcc;
    }
}
